'use strict';
const {
    Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
    class Caption extends Model {
        /**
         * Helper method for defining associations.
         * This method is not a part of Sequelize lifecycle.
         * The `models/index` file will call this method automatically.
         */
        static associate(models) {
            this.hasMany(models.Ship, {
                foreignKey: {
                    name: "caption_id",
                }
            });
            let _this = this;
            models.Ship.belongsTo(_this, {
                foreignKey: {
                    name: "caption_id",
                }
            })
        }
    }
    Caption.init({
        name: DataTypes.STRING,
        skillLevel: DataTypes.INTEGER,
    }, {
        sequelize, //传递的实例化后的对象
        modelName: 'Caption',
    });
    return Caption;
};